package com.ruoyi.water.mapper;

import com.ruoyi.water.domain.MeterData;
import org.apache.ibatis.annotations.Insert;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface MeterDataMapper extends CommonMapper<MeterData>  {
    /**
     * 批量插入并忽略重复记录
     */
    @Insert("<script>" +
            "INSERT IGNORE INTO t_meterdata (" +
            "meterId, meterName, readTime, readValue, recordTime" +
            ") VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.meterId}, #{item.meterName}, #{item.readTime}, " +
            "#{item.readValue}, #{item.recordTime})" +
            "</foreach>" +
            "</script>")
    int insertBatchIgnoreDuplicates(@Param("list") List<MeterData> list);
}
